package main

import (
	"context"
	"fmt"
	"go-web-learning/src/05_grpc/3_multi_server/1_one_proto/proto_go/multi_server"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"google.golang.org/grpc/grpclog"
)

func main() {
	addr := ":8080"
	conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		grpclog.Fatalf("Fail to dial %s: %s", addr, err.Error())
	}
	defer conn.Close()

	videoClient := multi_server.NewVideoServiceClient(conn)
	orderClient := multi_server.NewOrderServiceClient(conn)
	videoResp, _ := videoClient.Find(context.Background(), &multi_server.VideoReq{Id: 1, Name: "talonFind"})
	orderResp, _ := orderClient.Order(context.Background(), &multi_server.OrderReq{Id: 1, Name: "talonOrder"})
	fmt.Printf("func Find resp: %v\n", videoResp)
	fmt.Printf("func Order resp: %v\n", orderResp)
}
